package com.ft.core.utils.json;

import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.ObjectSerializer;
import com.alibaba.fastjson.serializer.SerializeWriter;

import java.io.IOException;
import java.lang.reflect.Type;

/**
 * @copyright (C), 2015-2019, 梵途科技有限公司
 * @fileName: TimeSerializer
 * @author: 李阳
 * @date: 2019/4/17 11:15
 * @description: 时间序列化
 */
public class TimeSerializer implements ObjectSerializer {

    @Override
    public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features)
            throws IOException {
        if (object == null) {
            serializer.getWriter().writeNull();
            return;
        }
        SerializeWriter out = serializer.getWriter();
        out.write(object.toString());
    }
}